//
//  DataCallResult.swift
//  JiaoZiTaxi
//
//  Created by Hu Gang on 2022/10/6.
//

import Foundation

// MARK: - DataCall
struct DataCallResult: Codable {
    let driverCounts: Int
    let id : Int?
    let workerID: Int?
    let price: Int?
    let name: String?
    let headavitor : String?
    let sex : Int?
    let age: Int?
    let zan: Int?
    let picture: String?
    let remark : String?
    let city : String?
    let intro, des: String?
    let phone: String?
    let laosPhone: String?
    let lat, lon : Double?
    let openid, chepai, carType: String?
    let carPicture: String?
    let err: Int
    
    
    
    enum CodingKeys: String, CodingKey {
        case driverCounts = "driver_counts"
        case id
        case workerID = "worker_id"
        case price, name, headavitor, sex, age, zan, remark, city, picture, intro, des, lat, lon, phone
        case laosPhone = "laos_phone"
        case openid, chepai
        case carType = "car_type"
        case carPicture = "car_picture"
        case err
    }
}

// MARK: - Encode/decode helpers

class JSONNull: Codable, Hashable {
    
    public static func == (lhs: JSONNull, rhs: JSONNull) -> Bool {
        return true
    }
    
//    public var hashValue: Int {
//        return 0
//    }

    func hash(into hasher: inout Hasher) {
        hasher.combine(0)
    }

    public init() {}
    
    public required init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        if !container.decodeNil() {
            throw DecodingError.typeMismatch(JSONNull.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Wrong type for JSONNull"))
        }
    }
    
    public func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()
        try container.encodeNil()
    }
}
